using System.Data;
using System;
using Library.Business;
namespace Library.Controller
{
    public partial class Controller_HoaDonNuoc: Cls_HoaDonNuoc
    {
        public static DataTable TaoDuLieuInHoaDon(string heThong, string loaiHinh, int thang, int nam)
        {
            try
            {
                DataTable dt = Get_Procerure.AUC_st_HoaDonNuoc_by_HeThong_LoaiHinh(heThong, loaiHinh, thang, nam);
                dt = Controller_HoaDonNuoc.Add_Column_HoaDonNuoc(dt);
                Cls_ThongTinGia_ChiTiet ThongTinGia_ChiTiet = Controller_ThongTinGia_ChiTiet.lay_ThongTinGia_ChiTiet(heThong, loaiHinh, thang, nam);
                foreach (DataRow dr in dt.Rows)
                {
                    string _LHDN = dr[Cls_LoaiHinhDoanhNghiep.fn_ID_LoaiHinhDoanhNghiep].ToString();
                    switch (_LHDN)
                    {
                        
                        case "SHHD":
                            dr[fn_LH1_DauKy] = dr[fn_DauKy];
                            dr[fn_LH1_CuoiKy] = dr[fn_CuoiKy];
                            dr[fn_LH1_SoM3TieuThu] = dr[fn_SoM3TieuThu];
                            dr[fn_LH1_DonGia] = ThongTinGia_ChiTiet.DonGia;
                            dr[fn_LH1_ThanhTien] = dr[fn_ThanhTien];
                             break;
                        case "HCSN":
                             dr[fn_LH2_DauKy] = dr[fn_DauKy];
                             dr[fn_LH2_CuoiKy] = dr[fn_CuoiKy];
                             dr[fn_LH2_SoM3TieuThu] = dr[fn_SoM3TieuThu];
                             dr[fn_LH2_DonGia] = ThongTinGia_ChiTiet.DonGia;
                             dr[fn_LH2_ThanhTien] = dr[fn_ThanhTien];
                             break;
                        case "KDDV":
                             dr[fn_LH4_DauKy] = dr[fn_DauKy];
                             dr[fn_LH4_CuoiKy] = dr[fn_CuoiKy];
                             dr[fn_LH4_SoM3TieuThu] = dr[fn_SoM3TieuThu];
                             dr[fn_LH4_DonGia] = ThongTinGia_ChiTiet.DonGia;
                             dr[fn_LH4_ThanhTien] = dr[fn_ThanhTien];
                             break;
                        case "SX":
                             dr[fn_LH3_DauKy] = dr[fn_DauKy];
                             dr[fn_LH3_CuoiKy] = dr[fn_CuoiKy];
                             dr[fn_LH3_SoM3TieuThu] = dr[fn_SoM3TieuThu];
                             dr[fn_LH3_DonGia] = ThongTinGia_ChiTiet.DonGia;
                             dr[fn_LH3_ThanhTien] = dr[fn_ThanhTien];
                             break;
                    }
                }
                return dt;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable AUC_st_ThongTinGia_Tao(int thang, int nam)
        {
            try
            {
                return DBcommon.getDataTable_produce("AUC_st_ThongTinGia_Tao"
                    , new SqlParameter_My().Thang(thang)
                    , new SqlParameter_My().Nam(nam)
                    );
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        //
        //

    }
}
